home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmiSoft / Dev / Src / Gl_bmp_load.lha / GL_BMP_Load / texture.c < prev    next >
Text File  |  2002-12-29  |  659b  |  29 lines

  1.  
  2. texture_t *LoadTextureFile(char *filename)
  3. {
  4.     BITMAPINFOHEADER texInfo;
  5.     texture_t *thisTexture;
  6.  
  7.     // allocate memory for the texture structure
  8.     thisTexture = (texture_t*)malloc(sizeof(texture_t));
  9.     if (thisTexture == NULL)
  10.         return NULL;
  11.  
  12.     // load the texture data and check validity
  13.     thisTexture->data = LoadBitmapFile(filename, &texInfo);
  14.     if (thisTexture->data == NULL)
  15.     {
  16.         free(thisTexture);
  17.         return NULL;
  18.     }
  19.  
  20.     // set width and height info for this texture
  21.     thisTexture->width = texInfo.biWidth;
  22.     thisTexture->height = texInfo.biHeight;
  23.  
  24.     // generate the texture object for this texture
  25.     glGenTextures(1, &thisTexture->texID);
  26.  
  27.     return thisTexture;
  28. }
  29.